

/*
 * File:




 */
#include <stdint.h>     /* standard types definitions */



//---------------------------------------- User Definition -------------------------------------------

#define		COMM_RX_FIFO_MAXLEN				(1<<12)
#define		COMM_RX_FRAME_MAXLEN			(1<<11)

#define		COMM_TX_FIFO_MAXLEN				(1<<7)
#define		COMM_TX_FRAME_MAXLEN			(1<<7)


//---------------------------------------- Structure Interface -------------------------------------------

typedef struct{
	uint8_t		Frame_len[2];
	uint8_t		Frame_src;
	uint8_t		Frame_src_l;
	uint8_t		Frame_dst;
	uint8_t		Frame_dst_l;
	uint8_t		Frame_type;
	uint8_t		Frame_cmd;
	uint8_t		Frame_data[64];
	
}COMMFRAME_STRUCT, *pCOMMFRAME_STRUCT;

typedef struct{
	uint8_t		RX_FIFO[COMM_RX_FIFO_MAXLEN];
	uint32_t	RX_FIFO_index_write;
	uint32_t	RX_FIFO_index_read;
	uint8_t		RX_FIFO_overflow_Flag;
	
	uint8_t		RxStartF;
	uint8_t		RxDLE;
	uint32_t	RxFrameLen;
	uint8_t		RxFrame[COMM_RX_FRAME_MAXLEN];	//without the reduplicate 0x10, the Head, and the Tail.
	COMMFRAME_STRUCT 	*rx;
	
	uint8_t		TX_FIFO[COMM_TX_FIFO_MAXLEN];
	uint32_t	TX_FIFO_len;
	uint32_t	TxFrameLen;
	uint8_t		TxFrame[COMM_TX_FRAME_MAXLEN];	//without the reduplicate 0x10, the Head, and the Tail.
	COMMFRAME_STRUCT 	*tx;
	
}COMMFIFO_STRUCT, *pCOMMFIFO_STRUCT;


//----------------------------- Function Interface -------------------------------------------

void		CommInitialization( COMMFIFO_STRUCT *comm );
void		CommWriteInFIFO( COMMFIFO_STRUCT *comm, uint8_t data );

void 		CommHandleFIFO( COMMFIFO_STRUCT *comm );
void 		CommPrepareTxFIFO( COMMFIFO_STRUCT *comm);

extern void CommHandler(COMMFIFO_STRUCT *comm);



uint16_t CommCalc_CRCByte(uint8_t *Buf, uint32_t Len);

///EOF










